home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / overscan.pas < prev    next >
Pascal/Delphi Source File  |  1994-06-22  |  2KB  |  99 lines

  1.  
  2. {$g+}
  3. program mode_x;
  4. { First mode-x routines, needs optimizing, by Bas van Gaalen, Holland, PD }
  5. uses crt;
  6. const vidseg:word=$a000;
  7. var x,y:word;
  8.  
  9. procedure setpal(col,r,g,b:byte); assembler; asm
  10.   mov dx,03c8h; mov al,col; out dx,al; inc dx; mov al,r
  11.   out dx,al; mov al,g; out dx,al; mov al,b; out dx,al; end;
  12.  
  13. procedure settextmode; assembler; asm
  14.   mov ax,3; int 10h; end;
  15.  
  16. procedure vga320x200; assembler;
  17. asm
  18.   mov ax,0013h     { mode 13h, 320x200x256x1 }
  19.   int 10h
  20.   mov dx,03c4h
  21.   mov ax,0604h     { unchain stuff: 320x200x256x4 }
  22.   out dx,ax
  23.   mov ax,0f02h     { select all planes }
  24.   out dx,ax
  25.  
  26.   mov cx,320*200   { clear graphics memory }
  27.   mov es,vidseg
  28.   xor ax,ax
  29.   mov di,ax
  30.   rep stosw
  31.   mov dx,03d4h
  32.  
  33.   mov dx,03c2h     { set 'overscan' mode here! }
  34.   mov al,10100011b
  35.   out dx,al
  36.  
  37. {
  38. 3C2h (W):  Miscellaneous Output Register
  39. bit   0  If set Color Emulation. Base Address=3Dxh else Mono Emulation.
  40.          Base Address=3Bxh.
  41.       1  Enable CPU Access to video memory if set
  42.     2-3  Clock Select
  43.           0: 14MHz(EGA)     25MHz(VGA)
  44.           1: 16MHz(EGA)     28MHz(VGA)
  45.           2: External(EGA)  Reserved(VGA)
  46.       4  (EGA Only) Disable internal video drivers if set
  47.       5  When in Odd/Even modes Select High 64k bank if set
  48.       6  Horizontal Sync Polarity. Negative if set
  49.       7  Vertical Sync Polarity. Negative if set
  50.          Bit 6-7 indicates the number of lines on the display:
  51.               0=200(EGA)  Reserved(VGA)
  52.               1=          400(VGA)
  53.               2=350(EGA)  350(VGA)
  54.               3=          480(VGA).
  55. Note: Set to all zero on a hardware reset.
  56. Note: On the VGA this register can be read from port 3CCh.
  57. }
  58.  
  59.   mov dx,03d4h     { misc mode-x stuff }
  60.   (*
  61.   mov ax,4009h     { add this one, if you want a higher resolution! }
  62.   out dx,ax
  63.   *)
  64.   mov ax,0014h
  65.   out dx,ax
  66.   mov ax,0e317h
  67.   out dx,ax
  68. end;
  69.  
  70. procedure putpixel(x,y:word; col:byte); assembler;
  71. asm
  72.   mov dx,03c4h
  73.   mov al,2
  74.   mov cx,[x]
  75.   and cx,3
  76.   mov ah,1
  77.   shl ah,cl
  78.   out dx,ax
  79.   mov es,vidseg
  80.   mov ax,[y]
  81.   shl ax,4
  82.   mov di,ax
  83.   shl ax,2
  84.   add di,ax
  85.   mov dx,[x]
  86.   shr dx,2
  87.   add di,dx
  88.   mov al,[col]
  89.   mov [es:di],al
  90. end;
  91.  
  92. begin
  93.   vga320x200;
  94.   for x:=1 to 127 do setpal(x,128-x div 2,128-x div 2,10);
  95.   for x:=0 to 319 do for y:=0 to 399 do putpixel(x,y,(x*x-y*y) mod 128);
  96.   repeat until keypressed;
  97.   settextmode;
  98. end.
  99.